package cn.holy.app.xcddt.utils

import cn.holy.app.xcddt.cons.AppUrl
import rx.Observable
import java.text.SimpleDateFormat
import java.util.*

/**
 * Created by 69568 on 2018/3/5.
 */
fun String.toImageUrl(): String {
    val url = AppUrl.BASE_URL
    return if (this.startsWith("https://") || this.startsWith("http://")) {
        this
    } else {
        url + "uploads/" + this
    }
}

fun Date.format(format: String): String {
    val formatter = SimpleDateFormat(format)
    val dateString = formatter.format(this)
    return dateString;
}

fun String.parseDate(format: String): Date? {
    val formatter = SimpleDateFormat(format)
    val date = formatter.parse(this)
    return date;
}
